package com.sunday.electric.utils;

import android.app.Activity;
import android.content.SharedPreferences;

import com.sunday.electric.base.BaseApplication;


/**
 *
 */
public class SharePerferenceUtils {
    private static SharePerferenceUtils instance;
    private SharedPreferences mSharedPreferences;

    private String nick;
    private String userId;
    private int headIcon;

    public String getNick() {
        return nick;
    }

    public String getUserId() {
        return userId;
    }

    public int getHeadIcon() {
        return headIcon;
    }

    private SharePerferenceUtils() {
        mSharedPreferences = BaseApplication.getInstance().getSharedPreferences("sunday_call",
                Activity.MODE_PRIVATE);
    }

    public static SharePerferenceUtils getIns() {
        if (null == instance) {
            instance = new SharePerferenceUtils();
        }

        return instance;
    }

    public void putBoolean(String key, boolean value) {
        mSharedPreferences.edit().putBoolean(key, value).commit();
    }

    public boolean getBoolean(String key, boolean defValue) {
        return mSharedPreferences.getBoolean(key, defValue);
    }

    public void putInt(String key, int value) {
        mSharedPreferences.edit().putInt(key, value).commit();
    }

    public int getInt(String key, int defValue) {
        return mSharedPreferences.getInt(key, defValue);
    }

    public void putString(String key, String value) {
        mSharedPreferences.edit().putString(key, value).commit();
    }

    public String getString(String key, String defValue) {
        return mSharedPreferences.getString(key, defValue);
    }

    public void putLong(String key, long value) {
        mSharedPreferences.edit().putLong(key, value).commit();
    }

    public long getLong(String key, long defValue) {
        return mSharedPreferences.getLong(key, defValue);
    }

    public void removeKey(String key) {
        mSharedPreferences.edit().remove(key).apply();
    }


}
